﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IllustratedCsharp7_ch8_chapt8_5
{
    class chapt8_5
    {
        static void _Main()
        {
            OtherClass oc = new OtherClass();
            oc.PrintField1();
        }
    }

    class SomeClass                      //基类
    {
        public string Filed1 = "Filed1 -- In the base class";
        public void Method1(string value)
        {
            Console.WriteLine($"Base class --Method1: {value}");
        }
    }
    class OtherClass : SomeClass                  //派生类
    {
        new public string Filed1 = "Filed1 -- In the derived class";//屏蔽基类成员
        new public void Method1(string value)             //屏蔽基类成员
        {
            Console.WriteLine($"OtherClass.Method1: {value}");
        }
        public void PrintField1()
        {
            Console.WriteLine(Filed1);  //访问派生类
            Console.WriteLine(base.Filed1); //访问基类
        }
    }
}
